<template>
    <div>
        <input type="date" v-model="state.mdateTime">
        <input type="button" value="查询" @click="funShow">
        <table>
            <tr>
                <th>编号</th>
                <th>名称</th>
                <th>图片</th>
                <th>操作</th>
            </tr>
            <tr v-for="item in list">
                <td>{{item.mid}}</td>
                <td>{{item.mname}}</td>
                <td>
                    <img :src="'https://localhost:7246' + item.mPhoto" alt="" width="50px" height="50px">
                </td>
                <td>
                    <input type="button" value="删除" @click="funDel(item.mid)">
                </td>
            </tr>
        </table>
    </div>
</template>

<script setup lang="ts">
import { reactive, toRefs, onMounted} from 'vue' 
import { useRoute, useRouter } from 'vue-router'
import axios from 'axios'

const route = useRoute()
const router = useRouter()

const date:any = reactive({
    state:{
        mdateTime:''
    },
  list:[]
})

const {state,list} = toRefs(date)




onMounted(()=>{
    funShow()
})

const funShow=()=>{
    axios({
        url:'https://localhost:7246/api/Login/ShowMember',
        method:'get',
        params:state.value
    })
    .then((res)=>{
        list.value = res.data.data
    })
    .catch((err)=>{
        console.log(err)
    })
}


const funDel = (mid:number)=>{
    if(confirm('确定删除吗？')){
        axios({
        url:'https://localhost:7246/api/Login/funDel',
        method:'get',
        params:{Mid:mid}
    })
    .then((res)=>{
        console.log(res)
        if(res.data.data >0){
            alert('删除成功')
            funShow()
        }
    })
    .catch((err)=>{
        console.log(err)
    })
        
    }
    
}

</script>

<style scoped>

</style>